package Interface;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class GameWindow extends JFrame
{
    public GameWindow()
    {
        //set parameters of main game window
        setTitle("Hot Tip");
        setSize(1024,768);
        setResizable(false);
        setLayout(new BorderLayout());

        //set look and feel of window and call method to add subcomponents
        initLookAndFeel("metal");
        buildWindow();

        //show window
         show();
    }

    /*
     * Set look and feel based on the parameter, log any error messages.
     */
    private void initLookAndFeel(String lookAndFeel)
    {
        if (lookAndFeel == null)
        {
            lookAndFeel = "metal";
        }
        if (lookAndFeel.equals("metal"))
        {
          lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
        }
        if (lookAndFeel.equals("system"))
        {
            lookAndFeel = UIManager.getSystemLookAndFeelClassName();
        }
        try {
                UIManager.setLookAndFeel(lookAndFeel);
            }
        catch (ClassNotFoundException ex) {
                Logger.getLogger(GameWindow.class.getName()).log(Level.SEVERE, null, ex);
            }
        catch (InstantiationException ex) {
                Logger.getLogger(GameWindow.class.getName()).log(Level.SEVERE, null, ex);
            }
        catch (IllegalAccessException ex) {
                Logger.getLogger(GameWindow.class.getName()).log(Level.SEVERE, null, ex);
            }
        catch (UnsupportedLookAndFeelException ex) {
                Logger.getLogger(GameWindow.class.getName()).log(Level.SEVERE, null, ex);
            }

    }

    private void buildWindow()
    {
        NorthPanel northPanel = new NorthPanel();
        SouthPanel southPanel = new SouthPanel();
        EastPanel eastPanel = new EastPanel();
        WestPanel westPanel = new WestPanel();

        JPanel centerPanel = new JPanel();
        centerPanel.setLayout(new GridLayout(1,2));

        centerPanel.add(westPanel);
        centerPanel.add(eastPanel);

        add(northPanel, BorderLayout.NORTH);
        add(centerPanel);
        add(southPanel, BorderLayout.SOUTH);
    }

}